﻿package Memoir 
{
	import Main.Memoir;
	import Main.Preloader;
	
	import org.flixel.*;
	
public class EndState extends FlxState
{
	
	private static const color:uint = 0xFFFFFF;
	private static const align:String = "center";
	private static const top:uint = 20;
	private static const br:String = '\n\n';
	
	public function EndState(numFound:uint)  {	
		// set background color (gray)
		FlxState.bgColor = 0xFF000000;
		
		var txt:FlxText = new FlxText(0, 260, FlxG.width, "The End.");	
		txt.setFormat("brooks", 64, color, align);
		this.add(txt);
		txt = new FlxText(0, 500, FlxG.width, numFound.toString() + " of 10 endings discovered.");
		txt.setFormat("peng", 16, color, align);
		this.add(txt);
		txt = new FlxText(0, FlxG.height-50, FlxG.width, "[Press X or click to Restart.]");
		txt.setFormat(null, 12, 0xaaaaaa, "center");
		this.add(txt);
		
	}
	override public function update():void {
		if (FlxG.keys.pressed("X") || FlxG.mouse.justReleased())
		{
			FlxG.fade.start(0xff000000, 1, onFade);
		}
		super.update();
	}
	private function onFade():void {
		Main.Memoir.alignments = new Array();
		FlxG.state = new MenuState();
	}
	
}
}